package com.ebai.product.management.controller.system;

import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ebai.product.management.base.controller.WebController;
import com.ebai.product.management.base.utils.Common;
import com.ebai.product.management.service.system.RoleAuthService;

import net.sf.json.JSONObject;

/**
 * 角色菜单权限管理
 * @author mgli
 *
 */
@Controller
@RequestMapping("/system/roleauth")
public class RoleAuthController extends WebController{
	
	@Autowired
	private RoleAuthService roleAuthService;

	/**
	 * 角色菜单权限管理主页面
	 * @param modelMap
	 * @return
	 */
	@RequestMapping("/index")
	@RequiresPermissions("system:roleauth:view")
    public String indexPage(ModelMap modelMap) {
		//modelMap.addAttribute("authList", this.roleAuthService.queryAuthsAll());
        return "system/roleauth/index";
    }
	
	/**
	 * 角色菜单权限管理-获取权限资源列表数据
	 * @param response
	 */
	@RequestMapping("/getRoleAuthsAll")
    public void getRoleAuthsAll(HttpServletResponse response, String rolePid) {
        JSONObject result = Common.getJsonResult(this.roleAuthService.queryAuthsAll(rolePid));
        this.sendDirectToClient(response, CONTENTTYPE_JSON, result.toString());
    }
}
